import { getAction, deleteAction, putAction, postAction, httpAction } from '@/api/manage'


const urlConfig = {
  '获取合同模板': { url: '/agreeModel/list', method: 'post' }, // parentId
  '内部综合同查询列表': { url: '/agree/integrated/listIntegratedAgree', method: 'post' }, // parentId
  '查询流程进度': { url: '/zx/work/queryWorkProgress', method: 'post' }, // parentId
  '合同中止发起': { url: '/agree/abort/initiate', method: 'post' }, // parentId
  '合同中止发起申诉': { url: '/agree/abort/agreeAbortAppeal', method: 'post' }, // parentId
  '合同中止详情': { url: '/agree/abort/details', method: 'get' }, // parentId
  '合同终止发起及修改': { url: '/agree/integrated/agreeTerminationCreate', method: 'post' }, // parentId
  '合同终止详情': { url: '/agree/integrated/getAgreeTerminationVo', method: 'get' }, // parentId
  '查询合同详情(发起)': { url: '/agreeInfo/detail', method: 'get' }, // parentId
  '查询合同详情(审核)': { url: '/agree/integrated/getAgreeByCheckId', method: 'get' },
  '合同中止解除发起': { url: '/agree/abort/relieve', method: 'post' },
  '判断是否允许操作': { url: '/agreeInfo/checkAgreeOp', method: 'post' },
  '根据合同id查询详情': { url: '/agree/abort/newDetails', method: 'get' },



}

const actionType = {
    get: (url, parameter) => {
        return getAction(url, parameter)
    },
    post: (url, parameter) => {
        return postAction(url, parameter)
    },
    put: (url, parameter) => {
        return putAction(url, parameter)
    },
    delete: (...args) => {
        return deleteAction(...args)
    },
    http: (url, parameter, method) => {
        return httpAction(url, parameter, method)
    },
}

export default (key, ...args) => {
    const tempConfig = urlConfig[key]
    let url =tempConfig.url
    if(tempConfig.isPost && tempConfig.isPost===true){
      const ll = []
      Object.keys(args[0]).forEach(key=>{
        ll.push(`${key}=${args[0][key]}`)
      })
      url += "?"+ll.join('&')
    }
    return actionType[tempConfig.method](url, ...args)
}



////////合同终止

//合同中止修改
export const getContractSuspension =
  (data) =>
    postAction(
      '/agree/abort/updateAgreeAbort',
      data
    )

//合同中止申诉更新
export const getContractAppeal =
  (data) =>
    postAction(
      '/agree/abort/appeaUpdate',
      data
    )

//合同中止解除修改法务通知函
export const getContractNotice =
  (data) =>
    postAction(
      '/agree/abort/relieveNoticeUpdate',
      data
    )

//合同终止发起及修改
export const getContractTermination =
  (data) =>
    postAction(
      '/agree/integrated/agreeTerminationCreate',
      data
    )


